<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="css/bootstrap.min.css"/>
    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="js/bootstrap.min.js"></script>
    <script src="js/jquery.min.js"></script>
</head>
<body>
<div class="text-right">
    <button type="button" id="add" class="btn btn-primary">
       新增
    </button>
</div>

<table class="table table-hover">
    <thead>
    <tr>
        <th>姓名</th>
        <th>地址</th>
        <th>手机号码</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody id="list">
    </tbody>
</table>

<script type="application/javascript">
        $("#add").bind('click',function () {
            window.location.href="./resumeInfo.html";
        })

        function findAll() {
            $.ajax({
                url: '/sss/resume',
                type: 'get',
                data: {},
                dataType: 'json',
                success: function (data) {
                    var html = '';
                    for (var i = 0; i < data.length; i++) {
                        html += " <tr><td>" + (data[i].name == null ? "" : data[i].name) + "</td>\n" +
                            "        <td>" + (data[i].address == null ? "" : data[i].address) + "</td>\n" +
                            "        <td>" + (data[i].phone == null ? "" : data[i].phone) + "</td>" +
                            "        <td><a onclick='deleteResume(" + data[i].id + ")'>删除</a>&nbsp;" +
                            "           <a onclick='updateResume(" + data[i].id + ")'>修改</a></td></tr>"
                    }
                    $('#list').html(html)

                },
                error:function () {
                    window.location.href="./index.html";
                }
            })
        }

        function deleteResume(id) {
            $.ajax({
                url: '/sss/resume/' + id,
                type: 'delete',
                data: {},
                dataType: 'json',
                async: false,
                success: function (data) {
                }
            })
            findAll();
        }

        function updateResume(id) {
            window.location.href="./resumeInfo.html?id="+id;
        }

        function init() {
            findAll();
        }

        init();


</script>
</body>
</html>